package config

import (
	"github.com/sirupsen/logrus"
	"gorm.io/gorm/logger"
)

type Config struct {
	ListenAddress string
	ListenPort    uint16
	LogLevel      logrus.Level
	LogFormat     logrus.Formatter
	MySQLDSN      string
	GormLogLevel  logger.LogLevel
}

var GlobalConfig = &Config{
	ListenAddress: "0.0.0.0",
	ListenPort:    9999,
	LogLevel:      logrus.InfoLevel,
	LogFormat:     &logrus.JSONFormatter{},
	MySQLDSN:      "root:123456@tcp(127.0.0.1:3306)/example?charset=utf8mb4",
	GormLogLevel:  logger.Warn,
}

func init() {
	logrus.SetLevel(GlobalConfig.LogLevel)
	logrus.SetFormatter(GlobalConfig.LogFormat)
}
